package org.ky.generator.util;

import org.ky.generator.config.GeneratorCofig;

import com.raddle.jdbc.JdbcTemplate;
import com.raddle.jdbc.datasource.DriverManagerDataSource;

/**
 * 数据库链接辅助类
 * 
 * @author K.y
 * @since 2018-12-05
 *
 */
public class JdbcHelper {
	/**
	 * 创建JDBC连接模版
	 * 
	 * @return
	 */
	public static JdbcTemplate createJdbcTemplate() {
		DriverManagerDataSource dataSource = new DriverManagerDataSource();
		dataSource.setDriverClassName(GeneratorCofig.getDBDriverCls());
		dataSource.setUrl(GeneratorCofig.getDBUrl());
		dataSource.setUsername(GeneratorCofig.getDBUsername());
		dataSource.setPassword(GeneratorCofig.getDBPassword());
		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		return jdbcTemplate;
	}
}
